package cloud.maque.admin.impl;

import cloud.maque.admin.domain.entity.MqMenuPrivilege;
import cloud.maque.admin.mapper.MqMenuPrivilegeMapper;
import cloud.maque.admin.service.MqMenuPrivilegeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 4color
 * @description 菜单权限
 * @date 2023-03-17
 */
@Service
public class MqMenuPrivilegeServiceImpl extends ServiceImpl<MqMenuPrivilegeMapper, MqMenuPrivilege> implements MqMenuPrivilegeService {

    @Override
    public boolean DeleteByMenuId(String menuId) {

        QueryWrapper<MqMenuPrivilege> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MqMenuPrivilege::getMenuId, menuId);
        return this.baseMapper.delete(queryWrapper) > 0 ? true : false;
    }

    @Override
    public boolean DeleteByPrivilegeId(String privilegeId) {
        QueryWrapper<MqMenuPrivilege> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MqMenuPrivilege::getPrivilegeId, privilegeId);
        return this.baseMapper.delete(queryWrapper) > 0 ? true : false;
    }

    @Override
    public List<String> GetRoleIdsByMenuId(String menuId) {
        List<String> arr = this.baseMapper.getRoleIdByMenuId(menuId);
        return arr;

    }

}
